/**
 * 作者:hanbo
 * 日期:2019/1/2316:26
 * 描述:
 */

define(["dojo/_base/declare", "esri/Map",
    "esri/views/MapView", "esri/geometry/Polygon", "esri/Graphic", "esri/layers/ImageryLayer"], function (declare, Map, MapView, Polygon, Graphic, ImageryLayer) {
    return declare("SmallMap", null, {
        constructor: function (id) {
            var image = new ImageryLayer({
                url: " http://localhost:6080/arcgis/rest/services/home_DBO_baseImage/ImageServer",
                format: "jpgpng", // 影像服务
                title: "影像"
            });
            this.map = new Map({
                layers: [image]
            });


            this.view = new MapView({
                container: id,
                map: this.map
            });
            this.view.ui.remove("attribution");
        },
        draw: function (json) {
            var that=this;
           this.view.when(function () {
               var polygon = new Polygon({
                   hasZ: false,
                   hasM: false,
                   rings: json.geometry.rings,
                   spatialReference: json.geometry.spatialReference
               });
               // 生成绘制的图形
               var graphic = new Graphic({
                   geometry: polygon,
                   symbol: {
                       type: "simple-line",
                       color: [255, 0, 0],
                       width: 2,
                       cap: "round",
                       join: "round"
                   }
               });
               // 将绘制的图形添加到view
               that.view.graphics.add(graphic);
               //设置地图范围
               that.view.extent = polygon.extent;
           });
        }
    })
});